import React, {Component} from 'react';
import {WeaDialog} from 'ecCom';
import { WeaLocaleProvider, WeaNewScroll } from 'ecCom';
import * as api from "../../api/signPlugin";
import {createWorkflow} from '../../util/pulbic-func';
import isEmpty from 'lodash/isEmpty';
const { getLabel } = WeaLocaleProvider;

export default class Workflow extends Component{
    constructor(props){
        super(props);
        this.state = {
            workflowList: []
        }
    }
    
    componentDidMount(){
        api.getWorkflowList().then(data => {
            if(data.status === '1'){
                this.setState({workflowList: data.result});
            }else{

            }
        }, error => {});
    }
    
    render(){
        const {wfDialogVisible, wfDialogCancelHandle} = this.props;
        const {workflowList} = this.state;
        return (
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@8z60ge`}
                visible={wfDialogVisible || false}
                className="new-hrm-workflow"
                onCancel={wfDialogCancelHandle}
                closable
                style={{width: 600, height: 400}}
                title = {getLabel('385037',"新建考勤流程")}
                icon="icon-portal-workflow"
                iconBgcolor='#0079de'
            >
                <div className="new-hrm-workflow-body">
                <div className="new-hrm-workflow-wrapper">
                    <div className="hearder"><i className="icon-coms-hrm"/>{getLabel('15882',"人事管理")}<span>(</span>{workflowList.length}<span>)</span></div>
                    <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@uo7hq9`} height={270}>
                    {
                    !isEmpty(workflowList) && workflowList.map((item)=> {
                        return <div className="cursor-pointer item" onClick={()=> createWorkflow(item)}>{item.title}</div>
                    })
                    }
                    </WeaNewScroll>
                </div>
                </div>
            </WeaDialog>
        )
    }
}